////////////////////////////////////////////////////////////////////////////////
// Filename: DirectX_10_Model.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _DirectX_10_Model_H_
#define _DirectX_10_Model_H_


//////////////
// INCLUDES //
//////////////

#include <OmenEngine>

#include <fstream>
using namespace std;

///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "DirectX_10_Texture.h"

#include <IOmenModel.h>

namespace Omen {
    ////////////////////////////////////////////////////////////////////////////////
    // Class name: DirectX_10_Model
    ////////////////////////////////////////////////////////////////////////////////
    class DirectX_10_Model : public Omen::IModel
    {
    private:
        struct VertexType
        {
            D3DXVECTOR3 position;
            D3DXVECTOR2 texture;
            D3DXVECTOR3 normal;
        };

        struct ModelType
        {
            float x, y, z;
            float tu, tv;
            float nx, ny, nz;
        };

        #define GUID_DIRECTX10_MODEL "9452D3E8-3271-49A1-8E03-743B994AD59A"

    public:
        virtual Omen_GUID classId() const { return OMEN_UUID(GUID_DIRECTX10_MODEL); }    /// <summary>Defines the class ID</summary>
        virtual Omen_GUID objectId() const { return newUUID(); }   /// <summary>Defines the object instance ID</summary>

        DirectX_10_Model();
        DirectX_10_Model(const DirectX_10_Model&);
        ~DirectX_10_Model();

        virtual int meshCount(void) const { return 0; }
        virtual void addMesh( IMesh* pMesh ) { };

        bool Initialize( ID3D10Device*, const WCHAR*, const WCHAR*);
        void Shutdown();
        void Render( ID3D10Device*);

        int GetIndexCount();
        ID3D10ShaderResourceView* GetTexture();

    private:
        bool InitializeBuffers( ID3D10Device*);
        void ShutdownBuffers();
        void RenderBuffers( ID3D10Device*);

        bool LoadTexture( ID3D10Device*, const WCHAR*);
        void ReleaseTexture();

        bool LoadModel(const WCHAR*);
        void ReleaseModel();

    private:
        ID3D10Buffer    *m_vertexBuffer, 
                        *m_indexBuffer;
        
        int             m_vertexCount, 
                        m_indexCount;

        DirectX_10_Texture* m_pTexture;
        ModelType*          m_model;
    };
} // namespace Omen

#endif